#!/bin/bash
#chkconfig: 35 50 50
#description: order3.3j

dir=/Zdata/cai/order_cai/
prog=order_s.php
pid=$dir'orders.php.pid'

start(){
        echo "正在启动服务...."
        php -q $dir$prog
        echo "启动完成"
}
stop(){
        echo "正在停止服务...."
        pid=$(cat $pid)
        kill $pid
        rm -rf $pid
        echo "服务已停止"
}
status(){
        if [ -e $pid ];then
            echo "$0 服务正在运行"
        else
            echo "$0 服务已经停止"
        fi
}
restart(){
        stop
        sleep 1 #延迟1秒
        start
}

case "$1" in
"start")
        start
        ;;
"stop")
        stop
        ;;
"status")
        status
        ;;
"restart")
        restart
        ;;
*)
        echo "用法：$0 start|stop|status|restart"
        ;;
esac

